<%--
  Created by IntelliJ IDEA.
  User: 86135
  Date: 2022/3/12
  Time: 9:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="javax,org,org.apache" %>
<%@ page import="org.apache.hadoop.hbase.HBaseConfiguration" %>
<%@ page import="com.sun.codemodel.internal.fmt.JStaticFile" %>
<%@ page import="org.apache.hadoop.conf.Configuration" %>
<%@ page import="java.io.IOException" %>
<%@ page import="org.apache.hadoop.hbase.TableName" %>
<%@ page import="org.apache.hadoop.hbase.Cell" %>
<%@ page import="org.apache.hadoop.hbase.util.Bytes" %>
<%@ page import="org.apache.hadoop.hbase.CellUtil" %>
<%@ page import="org.apache.hadoop.hbase.client.*" %>
<%@ page import="java.awt.image.ByteLookupTable" %>
<html>
<head>
    <script>

    </script>
    <title>Title</title>
    <style>
        td,th{
            white-space: nowrap;
            width: 75px;
            height: 40px;
            text-align: center;
        }
        .divcenter
        {
            width: 900px;
            height: 400px;
            background-color: aliceblue;
            overflow: auto;
            margin: auto;
        }
    </style>
</head>
<body bgcolor="#ffefd5">
<h1 align="center">学生信息展示查询</h1>
<div class="divcenter">
    <form action="/demo" style="text-align: center;margin-top: 20px">
        <input id="englishname" name="englishname" placeholder="按姓名查询">
        <input type="submit" value="查询" id="1">
        <input id="sid" name="sid" placeholder="按学号查询">
        <input type="submit" value="查询" id="2">
        <input id="sstatus" name="sstatus" placeholder="按状态查询">
        <input type="submit" value="查询" id="3">
        <input id="date" name="date" placeholder="按日期查询">
        <input type="sub/mit" value="查询" id="4">
        <input id="semeter" name="semeter" placeholder="按学期查询">
        <input type="submit" value="查询" id="5">
    </form>
    <table border="1" cellspacing="0" align="center">
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>入学日期</th>
            <th>电话号码</th>
            <th>学期</th>
            <th>在籍状态</th>
        </tr>

    </table>
</div>
<%!


    public static void getScan(String tableName) throws IOException {
        //用HBaseConfiguration.create()创建一个config对象
        Configuration conf = HBaseConfiguration.create();
        //说明要连接的ip地址
        conf.set("hbase.zookeeper.quorum","192.168.43.11");
        conf.set("hbase.zookeeper.property.clientport","2181");

        Connection conn = ConnectionFactory.createConnection(conf);
        Table table = conn.getTable(TableName.valueOf(tableName));

        //2、创建scan对象  左闭右开  右边不包括1005
        Scan scan = new Scan(Bytes.toBytes("1001"), Bytes.toBytes("1003"));

        //3、获取对象
        ResultScanner scanner = table.getScanner(scan);

        for (Result result : scanner) {
            for (Cell cell : result.rawCells()) {
                //打印数据
                System.out.println("Scan CF: " + Bytes.toString(CellUtil.cloneFamily(cell)));
                System.out.println("Scan CN: " + Bytes.toString(CellUtil.cloneQualifier(cell)));
                System.out.println("Scan Value: " + Bytes.toString(CellUtil.cloneValue(cell)));
            }
        }


        table.close();
    }
    public void yun() throws IOException {
        getScan("student");
    }
%>

</body>
</html>

